home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / c / bc_ti.zip / TI652.ASC < prev    next >
Text File  |  1992-02-25  |  1KB  |  67 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.   PRODUCT  :  C++                                    NUMBER  :  652
  9.   VERSION  :  All
  10.        OS  :  PC DOS
  11.      DATE  :  February 25, 1992                        PAGE  :  1/1
  12.  
  13.     TITLE  :  Interrupt Handlers as Member Functions
  14.  
  15.  
  16.  
  17.  
  18.   An  interrupt  handler  cannot  be  made  a  static member  of  a
  19.   class because  there is no way  to  pass such a function a 'this'
  20.   pointer.  It is possible, however, to overcome this difficulty by
  21.   creating  a  static  member  function  that is given access to  a
  22.   pointer to the class that is currently active. For example:
  23.  
  24.          class ISR {
  25.            public:
  26.              static void interrupt handler();
  27.              ISR *active;
  28.              void handle();
  29.          };
  30.  
  31.          void interrupt ISR::handler() {
  32.            active->handle();
  33.          }
  34.  
  35.   In this example,  ISR::handler()  is installed as the handler and
  36.   active must be set to point to a valid instance of ISR.
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.